package com.lxf.cloudotherserve.controller;

import com.alibaba.fastjson.JSONObject;
import com.lxf.cloudotherserve.annotate.OtherRateLimit;
import com.lxf.cloudotherserve.service.UserCommentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author 罗兴发
 * @data 2025/6/30 9:08
 * @description：用户评论-控制层
 */
@RestController
@CrossOrigin  //跨域
@RequestMapping("/v1")
@Slf4j
public class UserCommentController {
    @Resource
    UserCommentService userCommentService;


    /**
     * 添加评论
     * @param json
     * @return
     */
    @OtherRateLimit(value = 2,timeout = 5)
    @PostMapping("/addUserComment")
    public String addUserComment(@RequestBody JSONObject json, HttpServletRequest request){
        return userCommentService.addUserComment(json,request);
    }


    /**
     * 获取评论
     * @param json
     * @return
     */
    @OtherRateLimit(value = 2,timeout = 5)
    @PostMapping("/getUserComment")
    public String getUserComment(@RequestBody JSONObject json){
        return userCommentService.getUserComment(json);
    }

    /**
     * 删除评论
     * @param json
     * @return
     */
    @OtherRateLimit(value = 2,timeout = 5)
    @PostMapping("/delUserCommentById")
    public String delUserCommentById(@RequestBody JSONObject json, HttpServletRequest request){
        return userCommentService.delUserCommentById(json,request);
    }


    /**
     * 根据用户ID、对象ID、对象类型以及相应标识获取是否点赞/收藏
     * @return
     */
    @GetMapping("/delESUserComment")
    public int delESUserComment(){
        return userCommentService.delESUserComment();
    }

}
